package com.salestax.core.tests;

import java.math.BigDecimal;

import junit.framework.TestCase;

import com.salestax.core.Product;
import com.salestax.core.specific.product.Book;
import com.salestax.core.specific.product.FoodProduct;
import com.salestax.core.specific.product.ImportedProduct;
import com.salestax.core.specific.product.MedicalProduct;
import com.salestax.core.specific.product.NormalProduct;

public class TestSingleCases extends TestCase {
	
	public void testNormalProduct(){
		Product normalProduct = new NormalProduct("",12.5,1);
		assertEquals("13.75", normalProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("1.25",normalProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	
	public void testBookProduct(){
		Product book = new Book("test book",12.4,1);
		assertEquals("12.40", book.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.00", book.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	
	public void testFoodProduct(){
		Product food = new FoodProduct("test food product",12.4,1);
		assertEquals("12.40", food.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.00", food.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	
	public void testMedicalProduct(){
		Product medicalProduct = new MedicalProduct("test food product",12.4,1);
		assertEquals("12.40", medicalProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.00", medicalProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	public void testImportedMedicalProduct(){
		Product medicalProduct = new ImportedProduct("imported medical product",1,new MedicalProduct("test food product",10.0,1));
		assertEquals("10.50", medicalProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.50", medicalProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	public void testImportedBookProduct(){
		Product bookProduct = new ImportedProduct("imported medical product",1,new Book("test Book product",10.0,1));
		assertEquals("10.50", bookProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.50", bookProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	public void testImportedFoodProduct(){
		Product foodProduct = new ImportedProduct("imported medical product",1,new FoodProduct("test Book product",10.0,1));
		assertEquals("10.50", foodProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("0.50", foodProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
	public void testImportedNormalProduct(){
		Product foodProduct = new ImportedProduct("imported medical product",1,new NormalProduct("test Book product",10.0,1));
		assertEquals("11.50", foodProduct.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
		assertEquals("1.50", foodProduct.getContributingTax().setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
	}
}
